package com.cz.filter;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

public class FilterBySQLProducer {

    public static void main(String[] args) throws Exception {

        DefaultMQProducer producer = new DefaultMQProducer();
        producer.setNamesrvAddr("master:9876");
        producer.start();

        for (int i = 0; i < 10; i++) {
            try {
                byte[] body = ("Hi, " + i).getBytes();
                Message message = new Message("myTopic", "myTag", body);
                message.putUserProperty("age", i + "");
                SendResult sendResult = producer.send(message);
                System.out.println(sendResult);

            } catch (Exception e) {
                e.printStackTrace();
            }

        }

        producer.shutdown();


    }
}
